import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class denglujiemian extends JFrame{
    JButton guanliyuandenglu;//管理员登录
    JButton yonghudenglu;//用户登录
    JButton tuichu;//退出
    denglujiemianjianshiqi jianshiqi1;

    public denglujiemian()
    {
        chushihua();
        //setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    
    void chushihua()//初始化
    {
        setBounds(400,400,400,400);
        setTitle("羽毛球场地管理系统");

        jianshiqi1=new denglujiemianjianshiqi(this);

        setLayout(null);
        
        guanliyuandenglu=new JButton("管理员登录");
        add(guanliyuandenglu);
        guanliyuandenglu.setBounds(150,50,100,30);
        guanliyuandenglu.addActionListener(jianshiqi1);

        yonghudenglu=new JButton("用户登录");
        add(yonghudenglu);
        yonghudenglu.setBounds(150,100,100,30);
        yonghudenglu.addActionListener(jianshiqi1);
        
        tuichu=new JButton("退出");
        add(tuichu);
        tuichu.setBounds(150,150,100,30);
        tuichu.addActionListener(jianshiqi1);

        
    }
    
    void qiehuanjiemian(JButton anniu)//切换界面
    {
        if(anniu==guanliyuandenglu)
        {
            main.guanliyuandenglu();
        }
        else if(anniu==yonghudenglu)
        {
            main.yonghudenglu();
        }
        else if(anniu==tuichu)
        {
            main.tuichu();
        }
    }
    
    void tuichu()//退出
    {
        main.tuichu();
    }
}
class denglujiemianjianshiqi implements ActionListener//登录界面监听器
{

    denglujiemian denglujiemian1;

    denglujiemianjianshiqi(denglujiemian denglujiemian1)
    {
        this.denglujiemian1=denglujiemian1;
    }

    public void actionPerformed(ActionEvent e)//按按纽判定
    {
        if(e.getSource() ==denglujiemian1.guanliyuandenglu)//管理员登录按纽
        {
            denglujiemian1.qiehuanjiemian((JButton)e.getSource());
        }
        else if(e.getSource() ==denglujiemian1.yonghudenglu)//用户登录按纽
        {
            denglujiemian1.qiehuanjiemian((JButton)e.getSource());
        }
        else if(e.getSource()==denglujiemian1.tuichu)//退出按纽
        {
            denglujiemian1.tuichu();
        }
    }
}